//
//  PPTimelineAlbumModel.m
//  
//
//  Created by GaoYongyue on 16/9/25.
//
//

#import "PPTimelineAlbumModel.h"

@implementation PPTimelineAlbumModel
@synthesize comments;

// Insert code here to add functionality to your managed object subclass

+ (instancetype)existingAlbumForAlbumID:(NSNumber *)albumID
{
    PPTimelineAlbumModel *album = [self find:@{@"albumID" : albumID, @"currentUserID" : DGCurrentAccount.userID}];

    if(album == nil) {
        album = [PPTimelineAlbumModel create];
        album.albumID = albumID;
        album.currentUserID = DGCurrentAccount.userID;
        [album.managedObjectContext saveContext];
    }

    NSArray *comments = [PPTimelineComments where:@{@"albumID": albumID}];
    album.comments = comments;

    return album;
}
@end
